package io.lkt.modules.sys.service.impl;

import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import io.lkt.modules.sys.dao.WeixinInfoDao;
import io.lkt.modules.sys.entity.WeixinInfoEntity;
import io.lkt.modules.sys.service.WeixinInfoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;



@Service("weixinInfoService")
@DataSource("slave1")
public class WeixinInfoServiceImpl extends ServiceImpl<WeixinInfoDao, WeixinInfoEntity> implements WeixinInfoService {
    @Autowired
    WeixinInfoDao weixinInfoDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String brandName=params.get("brandName").toString();
        String weixinName=params.get("weixinName").toString();
        String weixinNikeName=params.get("weixinNikeName").toString();
        IPage<WeixinInfoEntity> page = this.page(
                new Query<WeixinInfoEntity>().getPage(params),
                new QueryWrapper<WeixinInfoEntity>().like(StringUtils.isNotBlank(weixinName),"weixin_name", weixinName).like(StringUtils.isNotBlank(weixinNikeName),"weixin_nike_name", weixinNikeName).like(StringUtils.isNotBlank(brandName),"brand_name", brandName)
        );

        return new PageUtils(page);
    }

    @Override
    public int insert(WeixinInfoEntity entity){
        return weixinInfoDao.insert(entity);
    }

    @Override
    public WeixinInfoEntity getById(Integer id){
        return weixinInfoDao.selectById(id);
    }

    @Override
    public int update(WeixinInfoEntity entity){
        return weixinInfoDao.updateById(entity);
    }
}
